<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <!-- 
    v-model:
    1) 作用: 实现数据和视图的双向数据绑定
       - 数据变化了, 视图会自动更新
       - 视图变化了, 数据会自动更新
    2) 语法
       v-model="变量"  
       
    亮点: v-model能够非常方便的实现表单数据的 设置 和 获取   
   -->
  <div id="app">
    账户：<input v-model="username" type="text"> <br><br>
    密码：<input v-model="password" type="password"> <br><br>
    <button @click="login">登录</button>
    <button @click="reset">重置</button>
  </div>
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        username: '',
        password: ''
      },
      methods: {
        login() {
          console.log('调用登录接口', this.username, this.password)
        },
        reset() {
          this.username = ''
          this.password = ''
        }
      }
    })
  </script>
</body>

</html>